﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test30.Util
{
    public struct NotNull<T>
    {
        public T Value { get; }

        public static implicit operator T(NotNull<T> notNull)
        {
            return notNull.Value;
        }

        public static implicit operator NotNull<T>(T maybeNull)
        {
            return new NotNull<T>(maybeNull);
        }
        public NotNull(T maybeNull)
        {
            if (maybeNull == null)
                throw new ArgumentNullException($"{maybeNull.ToString()} is null");
            Value = maybeNull;
        }
    }
}
